using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;

public partial class query : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Manager m = new Manager(true,"ConnectionString");
        if (IsPostBack && txtqry.Text.Length > 0)
        {
            try
            {
                DataSet ds = m.ExecuteQuery(txtqry.Text, "tbl");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    grdresults.DataSource = ds.Tables[0].DefaultView;
                    grdresults.DataBind();
                    lblerr.Visible = false;
                }
                else
                {
                    grdresults.Visible = false;
                    lblerr.Visible = true;
                    lblerr.Text = "No records found!!";
                }
            }
            catch (Exception ex)
            {
                lblerr.Visible = true;
                lblerr.Text = "EXCEPTION: " + ex.ToString();
            }
        }
    }
}
